<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>AGV 任务添加</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/oksub.css">
</head>
<body>
<div class="ok-body layui-container ">
    <form class="layui-form layui-form-pane ok-form">

        <div class="layui-row layui-col-space10">
                <div class="layui-col-md8 ">
                    <div class="layui-form-item">
                        <label class="layui-form-label">名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="taskName" placeholder="名称" autocomplete="off" class="layui-input"
                                   lay-verify="required">
                        </div>
                    </div>
                </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">监控地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="plcMonitorOffset" placeholder="监控偏移地址" autocomplete="off" class="layui-input"
                               lay-verify="required">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">完成地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="plcFinishOffset" placeholder="完成偏移地址" autocomplete="off" class="layui-input"
                               lay-verify="required">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">开始位置</label>
                    <div class="layui-input-block">
                        <input type="text" name="startLocation" placeholder="开始位置" autocomplete="off" class="layui-input"
                               lay-verify="required">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">结束位置</label>
                    <div class="layui-input-block">
                        <input type="text" name="endLocation" placeholder="结束位置" autocomplete="off" class="layui-input"
                               lay-verify="required">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">运行模板</label>
                    <div class="layui-input-block">
                        <input type="text" name="template" value="F01" placeholder="运行模板" autocomplete="off" class="layui-input"
                               lay-verify="required">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="state" value="1" title="开启" checked>
                        <input type="radio" name="state" value="0" title="关闭">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <input type="text" name="remark" placeholder="备注" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space15">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="add">添加保存</button>
                </div>
            </div>
        </div>
    </form>
</div>
<!--js逻辑-->
<script src="/layui/layui.js"></script>
<script>
    layui.use(["element", "jquery","form","layer"], function () {
        let form = layui.form;
        let $ = layui.jquery;
        var layer = layui.layer
        form.on("submit(add)", function (data) {
            /*layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });*/
           $.ajax({
                url:'/data/addAgvTask',
                type:'POST',
                data: data.field,
                success: function (response) {
                    if (response.code===200){

                        layer.msg(response.msg, {
                            time: 1800 // 2秒关闭（如果不配置，默认是3秒）
                        }, function() {
                            //刷新页面
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                        });

                    }else{
                        layer.msg(response.msg);
                    }
                }
           });
            return false;
        });



    });
</script>
</body>
</html>
